export default class LastMayday {
  palette(title,image,describe) {
    return ({
      width: '300px',
      height: '500px',
      borderRadius: '2px',
      views: [{
        type: 'text',
        text: title,
        css: {
          top: '50px',
          left: '30px',
          width: '210px',
          height: '40px',
          fontSize: '17px',
          maxLines: 1,
          lineHeight: '20px',
          color: '#333',
          align: 'left'
        }
      }, {
        type: 'image',
          url: 'https://fast.lanerzhao.com/qrcode_banner.jpg',
        css: {
          top: '90px',
          left: '15px',
          width: '270px',
          height: '150px',
          borderRadius: '2px',
          align: 'left'
        }
      }, {
        type: 'text',
        text: describe,
        css: {
          top: '250px',
          left: '30px',
          width: '270px',
          height: '35px',
          fontSize: '14px',
          maxLines: 2,
          lineHeight: '23px',
          color: '#ccc',
          align: 'left'
        }
      }, {
        type: 'text',
        text: '长按识别小程序码',
        css: {
          bottom: '80px',
          left: '30px',
          width: '120px',
          height: '35px',
          fontSize: '13px',
          lineHeight: '15px',
          borderRadius: '0px',
          maxLines: 1,
          color: '#ccc',
          align: 'left'
        }
      }, {
        type: 'text',
        text: '扫码和大家一起讨论吧',
        css: {
          bottom: '50px',
          left: '30px',
          width: '120px',
          height: '35px',
          fontSize: '13px',
          lineHeight: '15px',
          borderRadius: '0px',
          maxLines: 1,
          color: '#ccc',
          align: 'left'
        }
      }, {
        type: 'image',
        url: '../../images/qrcode.jpg',
        css: {
          bottom: '45px',
          left: '200px',
          width: '60px',
          height: '60px',
          borderRadius: '0px',
          align: 'left'
        }
      }]
    })
  }
}

const startTop = 50;
const startLeft = 20;
const gapSize = 70;
const common = {
  left: `${startLeft}rpx`,
  fontSize: '40rpx',
};

function _textDecoration(decoration, index, color) {
  return ({
    type: 'text',
    text: decoration,
    css: [{
      top: `${startTop + index * gapSize}rpx`,
      color: color,
      textDecoration: decoration,
    }, common],
  });
}

function _image(index, rotate, borderRadius) {
  return (
    {
      type: 'image',
      url: '/palette/avatar.jpg',
      css: {
        top: `${startTop + 8.5 * gapSize}rpx`,
        left: `${startLeft + 160 * index}rpx`,
        width: '120rpx',
        height: '120rpx',
        shadow: '10rpx 10rpx 5rpx #888888',
        rotate: rotate,
        borderRadius: borderRadius,
      },
    }
  );
}

function _des(index, content) {
  const des = {
    type: 'text',
    text: content,
    css: {
      fontSize: '22rpx',
      top: `${startTop + 8.5 * gapSize + 140}rpx`,
    },
  };
  if (index === 3) {
    des.css.right = '60rpx';
  } else {
    des.css.left = `${startLeft + 120 * index + 30}rpx`;
  }
  return des;
}
